<%-- 
    Document   : Left
    Created on : Apr 18, 2011, 3:37:26 PM
    Author     : ToanNhan
--%>

<%@page import="Pojos.DanhMucSanPham"%>
<%@page import="java.util.List"%>
<%@page import="org.hibernate.Query"%>
<%@page import="org.hibernate.Session"%>
<%@page import="org.hibernate.cfg.Configuration"%>
<%@page import="org.hibernate.SessionFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<div class="box" style="width: 100%;">
    <div style="width: 100%; background-color: blue; text-align: center;"><font color="White">Danh Mục</font></div>
    <div>
        <script type="text/javascript">
            function ShowSub(subId, flag)
            {
                var subMenu = document.getElementById(subId);
                if(flag == true)
                {
                    subMenu.style.visibility = "visible";
                }
                else
                {
                    subMenu.style.visibility = "hidden";
                }
            }
        </script>

        <style type="text/css">
            .menu {
                position: absolute;
                visibility: hidden;
            }
            .left td a:link , .left td a:visited , .left td a:active{
                text-decoration: none;
                background-image: url(image/back1.gif);
                display: block;
                margin: 0px;
                height: 28px;
                width: 170px;
                padding-top: 5px;
                padding-left: 20px;
                color: #000066;
            }
            .left td a:hover {
                text-decoration: none;
                background-image: url(image/hover%20back1.gif);
                display: block;
                height: 28px;
                width: 170px;
                padding-top: 5px;
                padding-left: 20px;
                color:#FF6600;
            }
        </style>

        <%
                    SessionFactory factory = new Configuration().configure("Pojos/hibernate.cfg.xml").buildSessionFactory();
                    Session sessionHiberate = factory.openSession();
                    Query query = sessionHiberate.createQuery("From DanhMucSanPham");
                    List<DanhMucSanPham> lstDanhMuc = query.list();
                    sessionHiberate.close();
                    factory.close();
        %>

        <table border="0">
            <tr>
                <td><table width="100%" cellspacing="0">
                        <!- Bắt đầu Menu LapTop->
                        <%
                                    for (DanhMucSanPham dm : lstDanhMuc) {
                        %>
                        <tr onmouseover="ShowSub('subLapTop',true);" onmouseout="ShowSub('subLapTop',false);">
                            <td>
                                <a href="/WebsiteBanHang/XemDanhSachSanPham.jsp?maDanhMuc=<%=dm.getMaDanhMuc()%>"><%=dm.getTenDanhMuc()%></a>
                            </td>
                        </tr>
                        <%}%>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</div>